package com.xtiim.battery.discharge.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum BatteryGroupNoEnum {
    ONE(1, 0x8000),
    TWO(2, 0x8008),
    THREE(3, 0x8010),
    FOUR(4, 0x8018);

    private Integer batteryGroupNo;
    private Integer address;

    public static Integer getAddress(Integer batteryGroupNo) {
        return Arrays.stream(BatteryGroupNoEnum.values())
                .filter(e -> e.getBatteryGroupNo().equals(batteryGroupNo))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("invalid battery group no"))
                .getAddress();
    }

}
